from rest_framework import serializers
from .models import *

class CodeSerializer(serializers.Serializer):
    phone=serializers.CharField(max_length=11)


class UserSerializer(serializers.ModelSerializer):
    code=serializers.CharField(max_length=6,write_only=True)
    class Meta:
        model=User
        fields=['username','password','phone','age','code']

    def create(self, validated_data):
        del validated_data['code']
        User.objects.create_user(**validated_data)







